/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.soc.cs5226.gui.dashboard.chart.controller;

import edu.soc.cs5226.gui.entities.DAO;
import edu.soc.cs5226.gui.entities.HealthStatus;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author huijia
 */
public class SharedPoolBeanController {
    private DAO chartDao;
    
    public SharedPoolBeanController ()
    {
        chartDao = new DAO();
    }
    
    //--------------------------------------------------------------------------
    // Chart intervals should range from 0 - 100 with
    // red Threshold the lowest value
    //--------------------------------------------------------------------------
    public List<Number> getChartIntervals()
    {
        List<Number> intervals = new ArrayList<Number>();
        try
        {
            HealthStatus memoryAreaBC = chartDao.getSPSHealthStatus();
            long yellowThreshold = memoryAreaBC.getyellowThres();
            long redThreshold = memoryAreaBC.getredThres();
            long maxiThreshold = 100;

            intervals.add(redThreshold);
            intervals.add(yellowThreshold);
            
            if (redThreshold>100)
            {
                maxiThreshold = redThreshold + 100;
            }
            intervals.add(maxiThreshold);
        }
        catch (Exception e)
        {
            intervals.add(30);
            intervals.add(70);
            intervals.add(100);
            e.printStackTrace();
        }
        
        return intervals;
    } // getChartIntervals
    
    //--------------------------------------------------------------------------
    // getCurrentValue will return current hitRatio
    //--------------------------------------------------------------------------
    public long getCurrentValue()
    {
        long currValue = 0;
        try
        {
            currValue = chartDao.getCurrHitRatio();
        }
        catch (Exception e)
        {
            currValue = 0;
            e.printStackTrace();
        }
        
        return currValue;
    } // getChartIntervals
}
